
{
    angular.module('studentStayOutLateListModule')
        .controller('studentStayOutLateListController',studentStayOutLateListController);
    studentStayOutLateListController.$inject = ['http.interfaces','$stateParams','$state'];
    function studentStayOutLateListController(interfaces,$stateParams,$state) {
        let vm = this;
        let collect = {
            info:[],
            str:[],
            dateList:[],
            college:'',
            dateChange:dateChange,
            studentInfo:studentInfo,
            getList:getList,
            active: Active
            
        };
        collect.active();//进入控制器后调用一次
        vm.collect = collect;//输出集合，提供给模板调用
        vm.interfaces=interfaces;
        /** Active方法
         * @desc 控制器触发时执行一次的方法
         * @constructor
         */
        function Active() {
            for(var x=0;x<7;x++) {
                var time = new Date().getTime() - (x + 1) * 24 * 60 * 60 * 1000;
                var year = new Date(time).getFullYear();
                var month = new Date(time).getMonth() + 1;
                var day = new Date(time).getDate();
                if(month<10) month="0"+month;
                if(day<10)　 day="0"+day;
                collect.dateList[x]=year+'-'+month+'-'+day;
            }

            if(interfaces.time==''){
                interfaces.time=collect.dateList[0];
            }
            collect.selectedDate=interfaces.time;
            getList();
        }
        function getList() {
            interfaces.outLateStudents({departId:$stateParams.id,search_Date:collect.selectedDate}).then(res=> {
                if (res.data.resultCode == 1) {
                    collect.info=res.data.data.list;
                    collect.college=collect.info[0].departName;
                }
            });
        }
        function studentInfo(id) {
            $state.go('tab.studentInfo3',{id:id});
        }
        function dateChange() {
            collect.getList();
        }
    }
}